/*******************************************************************************
 * Level Master 2000
 * Copyright (C) 2010 Christian Herzog
 * For more information see http://code.google.com/p/levelmaster2000/
 *
 * This file is licensed under the terms of the MIT license, see
 * http://www.opensource.org/licenses/mit-license.php for further information.
 ******************************************************************************/

#ifndef COMPONENT_BROWSER_H
#define COMPONENT_BROWSER_H

#include "ClassInfo.h"

#include<QCompleter>
#include<QDockWidget>
#include<QLineEdit>
#include<QTreeView>
#include<QTreeWidget>


class ComponentBrowser : public QDockWidget
{
    Q_OBJECT

public:
    ComponentBrowser( QWidget *parent, QList<ClassInfo> &componentInfo );

signals:
    void createComponent( QString componentName, QString className );

private slots:
    //QTreeWidgetItem clicked in component browser (needed for en/disabling add button):
    void itemClicked( QTreeWidgetItem *item, int column );

    //Add component button in the component browser clicked:
    void addClicked();

private:
    void init( QList<ClassInfo> &componentInfo );

    //Helps to build up the component browser. Calls itself recursively.
    void buildComponentBrowser( QTreeWidgetItem *parent, QString package );

    //Assuming that you got a QTreeWidget which is structured package->package->xxx->Class,
    //this function gets you the full qualified class name as a string,
    //which you can then use in flash.
    QString buildFullClassName( QTreeWidgetItem *item, bool isClass  );

    QTreeWidget* tree;

};

#endif
